//
//  CoverView.m
//  Speedex
//
//  Created by speeda on 2016/10/27.
//  Copyright © 2016年 speeda. All rights reserved.
//

#import "CoverView.h"
#import "OpenBoxView.h"
#import "OrdinaryView.h"
#import "PKView.h"

@implementation CoverView

+ (void)showCoverView {

    CoverView *view = [[CoverView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    view.backgroundColor = [UIColor blackColor];
    view.alpha = 0.0;
    [[UIApplication sharedApplication].keyWindow addSubview:view];
    
    [UIView animateWithDuration:0.2 animations:^{
        view.alpha = 0.6;
    }];
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {

    for (UIView *view in [UIApplication sharedApplication].keyWindow.subviews) {
        
        if ([view isKindOfClass:[OpenBoxView class]]) {
            
            [view removeFromSuperview];
        }
        if ([view isKindOfClass:[OrdinaryView class]]) {
            
            [view removeFromSuperview];
        }
        if ([view isKindOfClass:[PKView class]]) {
            
            [view removeFromSuperview];
        }
        if ([view isKindOfClass:[CoverView class]]) {
            
            [view removeFromSuperview];
        }
 
    }
}




@end
